package com.joesem.sale.client.db


class LoginTable private constructor() {
    companion object {
        val table by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { LoginTable() }
    }

    fun clearAccount() {
        DB.db.clear()
    }

    fun saveToken(account: String, token: String) {
        DB.db.saveString("${account}_token", token)
        DB.db.saveString("account", account)
    }

    fun getAccount() = DB.db.getString("account")

    fun getToken() = DB.db.getString("${getAccount()}_token")

    fun isLogin() = !getToken().isNullOrEmpty()
}

